from typing import List


class Solution:
    def findMaxAverage(self, nums: List[int], k: int) -> float:
        tem = pre = 0
        for i in range(k-1):
            tem += nums[i]
        ans = tem + nums[k-1]
        for i in range(k-1,len(nums)):
            tem += nums[i]
            ans = max(tem,ans)
            tem -= nums[pre]
            pre += 1
        return ans/k
